import request from "@/utils/request";

//获取-订单列表
export const getGoodsApi = (data) => {
  return request.get('/goods', { params: data })
}
//删除商品 --goods里的
export const delGoodsApi = (id) => {
  return request.delete('/goods/' + id)
}
//添加商品 add 里的
export const addgoodsApi = (data) => {
  return request.post(`/goods`, data)
}
//goods首页 的搜,编辑
//根据id查询商品
export const chaApi = (id) => {
  return request.get(`/goods/` + id)
}
//编辑商品
export const bjgoodsApi = (data) => {
  return request.put(`/goods/` + data.goods_id, data)
}




//获取-商品分类列表-三级下拉---这里一定要拼接params --有分页
export const getcategoriesApi = (data) => {
  return request.get('/categories', { params: data })
}
//添加分类

export const addApi = (obj) => {
  return request.post(`/categories`, obj)
}


//3个中间模块增删改查
// //获取-商品参数和属性
// export const attributesApi = (id, sel) => {
//   return request(`/categories/${id}/attributes`, {
//     params: {
//       sel: sel
//     }
//   })
// }
// //添加动态参数

// export const addmanyApi = (id, data) => {
//   return request.post(`/categories/${id}/attributes`, data)
// }
// //删除动态参数
// export const delApi = (id, attrid) => {
//   return request.delete(`categories/${id}/attributes/${attrid}`)
// }
// //获取编辑分类参数
// export const getApi = (id, attrid) => {
//   return request.get(`categories/${id}/attributes/${attrid}`)
// }
// //编辑参数
// export const bjiApi = (id, data) => {
//   return request.put(`categories/${id}/attributes/${data.attr_id}`, data)
// }
//渲染商品分类三级联动
export const getcates = () => {
  return request.get('/categories')
}
//添加动态参数或者静态属性
export const addGoods = (id, data) => {
  return request.post('categories/' + id + '/attributes', data)
}
// //获取-商品参数和属性
export const updateGoods = (id, sel) => {
  return request.get('/categories/' + id + '/attributes', { params: sel })
}
//删除按钮
export const delGoods = (id, attrid) => {
  return request.delete('categories/' + id + '/attributes/' + attrid)
}
//编辑按钮  
export const changeGoods = (id, attrid, data) => {
  return request.put('categories/' + id + '/attributes/' + attrid, data)
}


//tag---部分
//添加标签
export const addAttributes = (id, data) => {
  return request({
    url: `/categories/${id}/attributes/${data.attr_id}`,
    method: 'put',
    data: {
      attr_name: data.attr_name,
      attr_sel: data.attr_sel,
      attr_vals: data.attr_vals
    }
  })
}
//删除标签.
export const delpropApi = (id, attrId, attr_name, attr_sel, attr_vals) => {
  request.put(`categories/${id}/attributes/${attrId}`, {
    attr_name: attr_name,
    attr_sel: attr_sel,
    attr_vals: attr_vals,
  })
}




//商品分类 删除编辑
//删除分类
export const delcate = (id) => {
  return request.delete(`/categories/${id}/`)
}
//获取编辑分类
export const cate = (id) => {
  return request.get(`/categories/${id}/`)
}
//编辑分类
export const bjcate = (obj) => {
  return request.put(`/categories/${obj.cat_id}/`, {
    cat_name: obj.cat_name
  })
}




